﻿using Microsoft.Extensions.DependencyInjection;
using Stee.CAP8.MessageBus.Sagas.Core.Extensions;
using Stee.CAP8.MessageBus.Sagas.Core.Sagas;
using Stee.CAP8.MessageBus.Sagas.Order.Sagas.Data;
using Stee.CAP8.MessageBus.Sagas.Order.Services;
using System;

namespace Stee.CAP8.MessageBus.Sagas.Order
{
    class Program
    {
        static void Main(string[] args)
        {
            var services = new ServiceCollection();


            //使用kafkaEventStore
            services.UseKafkaEventStore().AddSaga()
                .UseEventBus(bus => { bus.HandleEvent(); });

            services.AddSingleton(typeof(IOrderService), typeof(OrderService));
            var orderService = services.BuildServiceProvider().GetService<IOrderService>();
            while (true)
            {
                Console.ReadLine();
                orderService.CreateOrder(new System.Collections.Generic.List<ProductInfo>
                {
                    new ProductInfo{Count=1,ProductId=Guid.NewGuid(),ProductName="",TotalPrice=22},
                    new ProductInfo{Count=2,ProductId=Guid.NewGuid(),ProductName="",TotalPrice=33},
                });

            }

        }
    }
}
